using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.CommonPage
{
    public partial class ClassList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) 
            {
                 DataBinds();
            }
        }

        protected void DataBinds() 
        {
            Gv_DataBinds();
        }

        protected void Gv_DataBinds() 
        {
            LabMS.BLL.Class Class = new LabMS.BLL.Class();
            List<LabMS.Model.Class> ls = new List<LabMS.Model.Class>();
            ls = Class.GetModelList(CombineStr());
            Gv_Class.DataSource = ls;
            Gv_Class.DataBind();

        }

        protected string CombineStr() 
        {
            string strWhere = "";
            if (ddl_SearcheType.SelectedValue =="0"&& !string.IsNullOrEmpty(tb_KeyWord.Text)) 
            {
                strWhere += " Class_Code like '" + tb_KeyWord.Text.Trim() + "'";
            }
            else if (ddl_SearcheType.SelectedValue == "1" && !string.IsNullOrEmpty(tb_KeyWord.Text)) 
            {
                strWhere += " Class_Name like '" + tb_KeyWord.Text.Trim() + "'";
            }
            return strWhere;
        }

        protected void btn_Search_Click(object sender, EventArgs e)
        {
            Gv_DataBinds();
        }

        protected void Gv_Class_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            Gv_Class.PageIndex = e.NewSelectedIndex;
            DataBinds();
        }

        protected void Gv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            e.Row.Attributes["style"] = "Cursor:pointer";
        }
    }
}
